﻿@model Syufy.BINLookup.Web.Models.cardBINDB

@{
    ViewBag.Title = "BIN Lookup";
}

<h2>BIN Lookup</h2>

@using (Html.BeginForm("Index", "BinLookup", FormMethod.Post, new { id = "BinLookupForm" }))
{
    <div>
        <dl class="dl-horizontal">
            <dt>@Html.Label("BIN Number:")</dt>
            <dd>@Html.TextBox("BinNumber", null, new { required = "required", maxlength = "6", @class = "form-control" })</dd>

            <dt>@Html.Label("Confirm BIN Number:")</dt>
            <dd>@Html.TextBox("ConfirmBinNumber", null, new { required = "required", maxlength = "6", @class = "form-control" })</dd>

            <dt>@Html.Label("Account Number:")</dt>
            <dd>@Html.TextBox("AccountNumber", null, new { required = "required", maxlength = "16", @class = "form-control" })</dd>

            <dt>@Html.Label("Override:")</dt>
            <dd>@Html.CheckBox("Override", new { data_toggle = "tooltip", data_placement = "right", data_original_title = "In the case of search that doesn’t return a card type, or an incorrect card type, check the override box, then select and save the actual card type." })</dd>

            <dt>@Html.Label("Card Type:", new { id = "CardTypeLabel", style = "display:none;" })</dt>
            <dd>@Html.DropDownList("CardType", new SelectList(new[] { "", "DEBIT", "CREDIT" }), new { style = "display:none;", @class = "form-control" })</dd>
        </dl>
        <button id="Submit" class="btn btn-primary btn-default">Search</button>
    </div>
}

@if (Request.HttpMethod == "POST")
{
    <hr />

    if (Model != null)
    {
        <div>
            <dl class="dl-horizontal">
                <dt>@Html.DisplayName("BIN Number")</dt>
                <dd>@Html.DisplayFor(model => model.cardBin)</dd>

                <dt>@Html.DisplayName("Card Brand")</dt>
                <dd>@Html.DisplayFor(model => model.cardBrand)</dd>

                <dt>@Html.DisplayName("Issuing Bank")</dt>
                <dd>@Html.DisplayFor(model => model.issuingBank)</dd>

                <dt>@Html.DisplayName("Card Type")</dt>
                <dd>@Html.DisplayFor(model => model.cardType)</dd>

                <dt>@Html.DisplayName("Country")</dt>
                <dd>@Html.DisplayFor(model => model.isoCountryName)</dd>
            </dl>
        </div>
    }

    if (Model != null || ViewBag.Override)
    {
        if (ViewBag.PersistError)
        {
            <label class="text-danger">Error saving to database.</label>
        }
        else
        {
            <label class="text-success">Successfully saved lookup to database.</label>
        }
    }
    else
    {
        <label class="text-warning">No results found.</label>
    }
}

@section Scripts {
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/app/binlookup-controller.js"></script>
}